<?php
/**
 * 系统参数
 *
 *
 */
class Sys_parameter_model extends Model
{

    var $name;
    
	var $value;

 
	

	function __construct()
    {
        parent::Model();
    }

	// --------------------------------------------------------------------

    /**
	 * load by name
	 *
	 *
	 */	
    function load($name)
    {
        if (!$name){
            return array();
        }

        $query = $this->db->get_where('sys_parameter',array('name' => $name));

        if ($row = $query->row_array()){
            return $row;
        }

        return array();
    }

	// --------------------------------------------------------------------

    /**
	 * 创建
	 *
	 *
	 */	
    function create()
    { 
	 
        $this->db->set('name', $this->name);
        $this->db->set('value', $this->value);	 
              
        return $this->db->insert('sys_parameter');
    }

	// --------------------------------------------------------------------

    /**
	 * 结果集
	 *
	 *
	 */	
    function find_sys_parameter()
	{
        $query = $this->db->get('sys_parameter');
        $rows = array();
        foreach ($query->result_array() as $row){          
 
			$rows[$row['name']] = $row['value'];
        }
		
        return $rows;
	}
    /**
	 * 结果集2
	 *
	 *
	 */	
    function find_sys_parameter_row()
	{
        $query = $this->db->get('sys_parameter');
        $rows = array();
        foreach ($query->result_array() as $row){          
 
			$rows[$row['name']] = $row;
        }
		
        return $rows;
	}
    // --------------------------------------------------------------------

    /**
	 * 更新
	 *
	 *
	 */	
    function update($name)
    {
        
        $this->db->set('value', $this->value);
		 
        $this->db->where('name', $name);
        return $this->db->update('sys_parameter');
    }
       
 
    // --------------------------------------------------------------------

    /**
	 * 删除
	 *
	 *
	 */	
    function delete($id)
    {        
		$this->db->where('id', $id);

        return $this->db->delete('sys_parameter'); 
    }

    // --------------------------------------------------------------------
 
 
   
    
    
}